<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html style="overflow-x:hidden;overflow-y:auto;"><head>
<title>邯郸微购物</title>		
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">        
<!-- Mobile Devices Support @begin -->
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta name="apple-mobile-web-app-capable" content="yes"> <!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="stylesheet" type="text/css" href="${ctxStatic }/shopping/common.css" media="all">
<link rel="stylesheet" type="text/css" href="${ctxStatic }/shopping/xq.css">
<link rel="stylesheet" type="text/css" href="${ctxStatic }/shopping/home-menu-8.css" media="all">
<link rel="stylesheet" type="text/css" href="${ctxStatic }/shopping/font-awesome.css" media="all">
<style type="text/css">
.px {
	background-color: transparent;
	color: #999999;
	display: block;
	width: 85%; 
	padding:10px;
	font-size: 16px;
	font-family:Arial, Helvetica, sans-serif;
	border:0;
	-webkit-appearance:none;
	border:1px solid #e7e7e7;
	-webkit-box-shadow: 0 0 3px 0 #eeeeee inset;
	-moz-box-shadow: 0 0 3px 0 #eeeeee inset;
	box-shadow: 0 0 3px 0 #eeeeee inset;
	border-radius: 3px;
}
</style>
<script src="${ctxStatic}/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript">

function update(){
	var unitprice=parseFloat($("#unitprice").html());
	var count=parseInt($("#count").val());
	$("#total").html(count*unitprice);
	$("#real").html(count*unitprice);
}


function add(maxCount){
	
	var count=parseInt($("#count").val());
	if(count<parseInt(maxCount)){
		$("#count").val(count+1);
	}else{
		$("#count").val(maxCount);
	}
	update();
}

function subtract(){
	var count=parseInt($("#count").val());
	if(count>1){
		$("#count").val(count-1);
	}else{
		$("#count").val(1);
	}
	update();
}

function checkCount(maxCount){
	var count=parseInt($("#count").val());
	var r =  /^[1-9]\d*$/;
	if(count<=0){
		$("#count").val(1);
	}
	if(count>parseInt(maxCount)){
		$("#count").val(maxCount);
	}
	if(!r.test($("#count").val())){
		$("#count").val(1);
	}
	
	update();
}

function checkScore(maxCount){
	var count=parseInt($("#score").val());
	var unitprice=parseFloat($("#unitprice").html());
	if(unitprice<count){
		$("#score").val(unitprice);
	}
	var r =  /^[1-9]\d*$/;
	if(count<=0){
		$("#score").val(1);
	}
	if(count>parseInt(maxCount)){
		$("#score").val(maxCount);
	}
	if(!r.test($("#score").val())){
		$("#score").val(1);
	}
}

</script>
</head>
<body>
<div class="body">
<header class="w-header" mon="type=header">
  <a class="arrow-wrap" href="javascript:history.back()" mon="content=back">
   <span class="arrow-left"></span>
  </a>
  <a href="index.html?uid=${uid }&wechatId=${wechatId}" class="home" mon="content=home"></a>
  <div class="text">订单详情</div>
</header>

<form class="p-submission" id="j-order-form-refresh" method="post" action="${ctxFront }/shopping/product/toPay">
<input type="hidden" name="user.id" value="${uid }">
<input type="hidden" name="uid" value="${uid }">
<input type="hidden" name="wechatId" value="${wechatId }">
<input type="hidden" name="address.id" value="${address.id }">
<input type="hidden" name="name" value="${product.name }">
<input type="hidden" name="product.id" value="${product.id }">

<input type="hidden" name="status" value="0">

<section class="order-info">
<ul>
    <input name="dealType" value="1" type="hidden">
    <input name="dealTinyUrl" value="swdbwplc" type="hidden">
    <input name="dealPrice" value="40000" type="hidden">
    <li class="order-title">
      <div class="short-title">${product.name }</div>
      <div class="sub-title">库存数量：${product.amount }</div>
    </li>
    <li class="order-common-item">
      <dt>单价</dt>
      <dd>￥<span id="unitprice">${product.price/100 }</span></dd>
    </li>
    <div class="no-combo">
      <li class="j-product-number order-number" data-buylimit="50">
        <div class="product-number-changed">
        <span class="j-linkage order-btn minus minus-disabled" onclick="subtract(${product.amount});" ></span>
        <input id="count" class="j-number" name="productNumber" value="1" type="tel"  onblur="checkCount(${product.amount})">
        <span class="j-linkage order-btn plus plus-active"   onclick="add(${product.amount});"></span>
        </div>
        <div class="deal-options-title">数量</div>
      </li>
    </div>
    <c:if test="${product.payByScore eq '1' }">
		    <div class="no-combo">
		      <li class="j-product-number order-number" data-buylimit="50"  style="padding-right:0px;" >
		        <div class="product-number-changed">
		        <input id="score" class="j-number" name="score" value="1" type="tel"  onblur="checkScore(${member.score})">
		        </div>
		        <div class="deal-options-title">可用积分（${member.score}分） <br/>  <span style="color:red;font-size:12px;" >注：一元一分</span> </div>
		      </li>
		    </div>
    </c:if>
    <li class="order-common-item">
      <dt>总价</dt>
      <dd>¥<span id="total" class="j-amount-price">${product.price/100 }</span></dd>
    </li>
    <li class="j-privilege-info order-common-item common-item-hide">
      <dt>优惠</dt><dt>
      </dt><dd class="j-privilege-detail">
      </dd>
    </li>
    <li class="order-common-item">
      <dt>实付款</dt>
      <dd class="common-color-pink">￥<span id="real"  class="j-total-price">${product.price/100 }</span></dd>
    </li>
   <li class="order-common-title free-login">
     <dt>收货地址</dt> 
    </li>
     <a href="${ctxFront }/shopping/chooseAddressList?uid=${uid }&wechatId=${wechatId}&productId=${product.id}">
     <c:if test="${address ne null }">
		    <li class="order-consume-tip" style="height:58px;line-height:25px;">
		     <span style="color:#000000;font-size:19px;">${address.name }&nbsp;${address.mobile }</span><br/>
		    <span style="color:#D0D0D0;">${address.province }&nbsp;${address.city }&nbsp;${address.county }&nbsp;${fn:substring(address.detail,0,9) }</span> 
		    </li>
     </c:if>
      <c:if test="${address eq null }">
		    <li class="order-consume-tip" style="height:58px;line-height:25px;text-align:center;padding-top:2%;">
					<span>请设置您的设置地址</span>
		    </li>
     </c:if>
    </a>
    <li class="order-common-title free-login">
     <dt>配送备注</dt> 
    </li>
    <li class="order-consume-tip" style="height:58px;line-height:25px;padding-top:10px;">
		    <input name="remarks"  type="text" class="px">
    </li>
    
    <li class="order-button">
    <c:if test="${empty address.id }">
    <input class="order-common-button btn-submit j-order-submit" value="提交订单" type="button" onclick="alert('请选择地址');" >
    </c:if>
    <c:if test="${not empty address.id}">
      <input class="order-common-button btn-submit j-order-submit" value="提交订单" type="submit">
    </c:if>
    </li>
</ul>
</section>
</form>





</div>
</body>
</html>
